package c2.advanced.business.demo.po;

import easy.java.time.DateTool;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

@Document(DemoBook.COLLECTION)
@Data
public class DemoBook {

    public static final String COLLECTION = "demo_book";

    @Id
    private int uid;

    private String name;

    private String type;

    private Date pubTime;

    private Object ext;

    public static DemoBook create(int uid, String name, String type, String pubTimeStr, Object ext) {
        DemoBook book = new DemoBook();
        book.uid = uid;
        book.name = name;
        book.type = type;
        book.pubTime = DateTool.instance().parseOrNull(pubTimeStr);
        book.ext = ext;
        return book;
    }
}
